package com.xiaotu.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 张晓
 * @create 2020-06-21 19:38
 */
//University 就是 Composite ,可以管理College
public class University extends OrganizationComponent {

    List <OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();

    public University(String name, String des) {
        super(name, des);
    }

    //重写add
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }


    //重写remove
    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public String getDes() {
        return super.getDes();
    }

    //print方法，就是输出University 包含的学院
    @Override
    protected void print() {
        System.out.println("-----------"+ getName() +"-----------");
        //遍历
        organizationComponents.forEach(s->s.print());
    }
}
